using System.Web.Mvc;
using Animoso.Domain;
using Animoso.Domain.Data;

namespace Animoso.Web.Controllers
{
    public class PageController : ApplicationController
    {
        private IPageRepository _repository;

        public PageController(IPageRepository repository)
        {
            _repository = repository;
        }

        //
        // GET: /Page/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Open(int id)
        {
            Page page = _repository.GetById(id);
            return View(page);
        }

        //
        // GET: /Page/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Page/Create

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Content/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Content/Edit/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
